﻿<navigation:Page xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"  
    x:Class="QLNS.Views.Employee" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:ds="clr-namespace:QLNS.Web.Services" 
    xmlns:dataForm="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.DataForm.Toolkit"
                 
    mc:Ignorable="d" 
    xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
    d:DesignWidth="640" 
    d:DesignHeight="480" 
    Title="Employee Page" 
    xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation">
    <Grid x:Name="LayoutRoot">

        <Grid.RowDefinitions>
            <RowDefinition Height="auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <telerik:RadGridView Name="radGridView1" AutoGenerateColumns="False" Grid.Row="0" ItemsSource="{Binding Data, ElementName=employeeDatasourse}">
            <telerik:RadGridView.Columns>
                 <telerik:GridViewDataColumn Header="ID" DataMemberBinding="{Binding id}" />
                <telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}" />
                <telerik:GridViewDataColumn Header="Address" DataMemberBinding="{Binding Address}" />
                <telerik:GridViewDataColumn Header="Email" DataMemberBinding="{Binding Email}" />
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>
        <dataForm:DataForm x:Name="dataForm1" Grid.Row="1" Header="Employee Information"
        AutoGenerateFields="False" HorizontalAlignment="Left"
        AutoEdit="False" AutoCommit="False" Width="400"
        CurrentItem="{Binding SelectedItem, ElementName=radGridView1}" EditEnded="dataForm1_EditEnded">
            <dataForm:DataForm.EditTemplate>
                <DataTemplate>
                    <StackPanel>
                        <dataForm:DataField Label="Employee ID">
                            <TextBox IsReadOnly="True" 
              Text="{Binding Id, Mode=OneWay}" />
                        </dataForm:DataField>

                        <dataForm:DataField Label="Employee Name" >
                            <TextBox IsReadOnly="False" 
              Text="{Binding Name, Mode=TwoWay, ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" />
                        </dataForm:DataField>
                        <dataForm:DataField Label="Employee Address ">
                            <TextBox IsReadOnly="False"  
              Text="{Binding Address, Mode=TwoWay, ValidatesOnDataErrors=True,ValidatesOnNotifyDataErrors=True}" />
                        </dataForm:DataField>

                        <dataForm:DataField Label="Employee Email">
                            <TextBox IsReadOnly="False" 
              Text="{Binding Id, Mode=TwoWay}" />
                        </dataForm:DataField>
                    </StackPanel>
                </DataTemplate>
            </dataForm:DataForm.EditTemplate>
        </dataForm:DataForm>

        <riaControls:DomainDataSource Name="employeeDatasourse" QueryName="GetTblEmployees" >
            <riaControls:DomainDataSource.DomainContext>
                <ds:EmployeeContext></ds:EmployeeContext>
            </riaControls:DomainDataSource.DomainContext>
        </riaControls:DomainDataSource>



    </Grid>
</navigation:Page>
